/*
 * @Description: 
 * @Version: 2.0
 * @Author: Symbol_Yang
 * @Date: 2022-08-02 10:49:26
 * @LastEditors: Symbol_Yang
 * @LastEditTime: 2022-10-11 15:39:13
 */
const mongoose = require('mongoose')
const {Schema} = mongoose
//


var ShortMsgLogSchema = new Schema({
    
    enterprise_id: {type: Schema.Types.ObjectId, ref: 'enterprise', required: true}, // 关联企业

    cabinet_id: {type: Schema.Types.ObjectId, ref: 'cabinet', required: true}, // 关联柜
    
    content: {type: String, default: ""}, // 短信内容

    short_msg_id: { type: Schema.Types.ObjectId, ref: 'short_msg', required: true }, // 短信模板

    send_phone: {type: String, required: true}, //  接收人手机号  

    send_status: {type: Number, enum: [1,2,3] , default: 1}, // 发送状态 1 待发送  2 已发送、异常

    remarks: {type: String}, // 备注，存储发送结果

    create_at: {type: Date, default: Date.now, index: -1},
    update_at: {type: Date, default: Date.now},
})

ShortMsgLogSchema.pre('save', function (next) {
    let now = new Date()
    this.update_at = now
    next()
})
mongoose.model('short_msg_log', ShortMsgLogSchema)
module.exports = ShortMsgLogSchema
